package com.study.block_handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import com.study.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 自定义通用的限流处理逻辑
 */
@Slf4j
public class StudyBlocHandler {

    //必须是 static 的
    public static CommonResponse<String> studyHandlerBlockException(BlockException exception){

        log.error("trigger study block handler:[{}],[{}],[{}]",
                JSON.toJSONString(exception.getRule()),exception.getRuleLimitApp());

        return new CommonResponse<>(
                -1,
                "flow rule trigger block exception",
                null
        );
    }
}
